package com.xdk.templatescala.controller;

import com.xdk.templatescala.common.response.Result;
import com.xdk.templatescala.common.response.ResultBuild;
import com.xdk.templatescala.model.ScaleAnswerEntry;
import com.xdk.templatescala.service.ScaleAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @menu 量表模板
 * @author zhanghao
 **/
@RestController
@RequestMapping("/scaleAnswer")
public class ScaleAnswerController {

    @Autowired
    private ScaleAnswerService scaleAnswerService;
    /**
     * 新增量表答案
     *
     * @return
     */
    @PostMapping(value = "/addScaleAnswer")
    public Result<List<ScaleAnswerEntry>> addScaleAnswer(@RequestBody List<ScaleAnswerEntry> scaleAnswerEntries) {
        return ResultBuild.success(scaleAnswerService.addScaleAnswerEntry(scaleAnswerEntries));
    }

    /**
     * 获取所有量表答案
     *
     * @return
     */
    @GetMapping(value = "/getAllScaleAnswer")
    public Result<List<ScaleAnswerEntry>> getAllScaleAnswer() {
        return ResultBuild.success(scaleAnswerService.findScaleAnswerEntryByParam());
    }

    /**
     * 根据scaleId获取模板
     *
     * @return
     */
    @GetMapping(value = "/getScaleAnswer/{scaleAnswerIds}")
    public Result<List<ScaleAnswerEntry>> getScaleAnswer(@PathVariable("scaleAnswerIds") String scaleAnswerIds) {
        return ResultBuild.success(scaleAnswerService.findAllById(scaleAnswerIds));
    }

}
